function numeric(event)
{
    var unicode=event.charCode? event.charCode : event.keyCode
    if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
        if (unicode<48||unicode>57) //if not a number
        {
            event.returnValue=false;
            event.preventDefault();
            return false //disable key press
        }
    }
    if (event.keyCode == '13') {
        event.preventDefault();
    }
}
function equalize(id)
{
    
    
    var tmin=$("#"+id+"Min");
    var tmax=$("#"+id+"Max");
    
    var vmin=Number(tmin.val());
    var vmax=Number(tmax.val());
    
    if(vmin>vmax)tmax.val(vmin);
    $( "#"+id+"Range" ).slider( "values", 0, vmin );
    $( "#"+id+"Range" ).slider( "values", 1, vmax );
}

function initializeAdvQuery()
{
    parseTable();
// regSlider("TotalArea");
}

function regSlider(id)
{ 
    $( "#"+id+"Range" ).slider({
        range: true,
        min: 0,
        max: 1000,
        values: [ 10, 70 ],
        slide: function( event, ui ) {
            $( "#"+id+"Min" ).val( ui.values[ 0 ]);
            $( "#"+id+"Max" ).val( ui.values[ 1 ]);
        }
    });
                
    $( "#"+id+"Min").val($( "#"+id+"Range" ).slider( "values", 0 ));
    $( "#"+id+"Max").val($( "#"+id+"Range" ).slider( "values", 1 ));
    $( "#"+id+"Min").keypress(function (){
        numeric(event);
    })
    $( "#"+id+"Max").keypress(function (){
        numeric(event);
    })
    
    $( "#"+id+"Min").change(function (){
        equalize(id);
    })
    $( "#"+id+"Max").keyup(function (){
        equalize(id);
    })
        
}

function prepare_newadvert_form()
{
    document.getElementById('address').disabled=true;  
    document.getElementById('address').value=document.getElementById('address_input').value
}
function pressEdit()
{
    document.getElementById('address').disabled=false;
    return false
}
function changedEdit()
{
    document.getElementById('address_input').value=document.getElementById('address').value
}
function prepareEdit()
{
    changedEdit();
}

initArray.push(initializeAdvQuery);  



